<template>
  <div
    v-if="loaded"
    class="container enroll"
  >
    <div class="teamdata-header">
      <image
        class="teamdata-header-logo"
        :src="club.logo"
      ></image>
      <div class="teamdata-header-title">
        {{ club.name }}
      </div>
      <div class="header-info">
        <div
          v-for="(item,index) in pannels"
          :key="index"
          class="header-info-item"
        >
          <div class="header-info-item-content">
            {{ item.text }}
          </div>
          <div class="header-info-item-text">{{ item.label }}</div>
        </div>
      </div>
    </div>
    <van-tabs
      v-model="active"
      swipeable
      sticky
      animated
      title-active-color="#ee732f"
      :ellipsis="false"
      color="#ee732f"
    >
      <van-tab
        v-for="(item,index) in tabs"
        :key="index"
        :title="item.title"
        :name="item.id"
      >
        <div v-if="item.id == 1">
          <sport :seasons="seasons" />
        </div>
        <div v-else-if="item.id == 2">
          <record :achievements='achievements'></record>
        </div>
        <div v-else-if="item.id == 3">
          <data :club="club" />
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import Sport from '@/components/teamdata/sport'
import Record from '@/components/teamdata/record'
import Data from '@/components/teamdata/data'

import { getClubApi } from '@/api'
export default {
  components: {
    Sport,
    Record,
    Data
  },

  data () {
    return {
      loaded: false,
      club: null,
      pannels: [],
      seasons: [],
      achievements: [],
      tabs: [
        {
          id: '1',
          title: '赛季',
          icon: '/static/images/saicheng_1.jpg'
        },
        {
          id: '2',
          title: '战绩',
          icon: '/static/images/saicheng_1.jpg'
        },
        {
          id: '3',
          title: '资料',
          icon: '/static/images/saicheng_1.jpg'
        }
      ]
    }
  },
  onShow () {
    this.onLoadData()
  },
  methods: {
    onLoadData () {
      getClubApi().then(res => {
        const {club, pannel, seasons, achievements} = res
        this.club = club
        this.pannels = pannel
        this.achievements = achievements
        this.seasons = seasons
        this.loaded = true
      })
    }
  }
}
</script>

<style lang="less">
.container {
  background: #f7f7fa;
}
.teamdata-header {
  background-color: #ee732f;
  text-align: center;
  padding: 15px 0px;
  &-logo {
    width: 70px;
    height: 70px;
  }
  &-title {
    font-size: 16px;
    color: #fff;
    font-weight: 800;
  }
}
.header-info {
  margin: 20px 0px 0px 0px;
  display: flex;
  justify-content: space-between;
  &-item {
    width: 100%;
    line-height: 20px;
    text-align: center;
    &-content {
      font-size: 14px;
      color: #fff;
    }
    &-text {
      font-size: 12px;
      color: #eee;
      margin-top: 5px;
    }
    &-split {
      width: 1px;
      height: 20px;
      background-color: #eee;
      margin: auto 0px;
    }
  }
}
.tab-image {
  width: 100%;
}
</style>
